package ve.com.wayoyo.wuml_case.DibujoDiagramas;

import java.util.ArrayList;

import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.Rect;

public class CompConector {

	private int _fatherId;
	private int _childId;
	
	//Puntos para dibujar la linea
	private Point[] _points = new Point[5];

	
	//Cantidad de puntos
	private int _numberOfPoints;
	
	//Tipos de Terminaciones de los conectores
	public static class  _arrowType{
		protected static int None = 0;
		protected static int Flecha_Vacia = 1;
		protected static int Flecha_Direccion = 2;
		protected static int Agregacion = 3;
		protected static int Composicion = 4;
		protected static int PataDeGallo_PK = 5;
		protected static int PataDeGallo = 6;
		protected static int Union_Simple = 7;
		protected static int Flecha_Llena = 8;
	}
	
	//Terminaciones
	private int _fatherArrowType;
	private int _childArrowType;
	public int get_fatherId() {
		return _fatherId;
	}
	
	//Pinters
	private Paint _normalLinePaint;
	

	public CompConector(int fatherID,int childID){
		super();
		_fatherId = fatherID;
		_childId = childID;
		_normalLinePaint = new Paint();
		_normalLinePaint.setColor(Color.BLACK);
		_normalLinePaint.setStrokeWidth(3);
		
	}
	
	public void set_fatherId(int _fatherId) {
		this._fatherId = _fatherId;
	}
	public int get_childId() {
		return _childId;
	}
	public void set_childId(int _childId) {
		this._childId = _childId;
	}
	public int get_numberOfPoints() {
		return _numberOfPoints;
	}
	public void set_numberOfPoints(int _numberOfPoints) {
		this._numberOfPoints = _numberOfPoints;
	}
	public int get_fatherArrowType() {
		return _fatherArrowType;
	}
	public void set_fatherArrowType(int _fatherArrowType) {
		this._fatherArrowType = _fatherArrowType;
	}
	public int get_childArrowType() {
		return _childArrowType;
	}
	public void set_childArrowType(int _childArrowType) {
		this._childArrowType = _childArrowType;
	}
	
	public void setPointOfLine(int posX,int posY,int index){
		try{
			_points[index].set(posX, posY);
		}catch (Exception e){
			
		}
	}
	
	public void Dibujar(Canvas c,boolean isFcoused,float globalScale,int offSetX,int offSetY) {
		for (int i = 0; i < _numberOfPoints; i++) {
			if(i != _numberOfPoints-1){
				c.drawLine((_points[i].x+offSetX)*globalScale, (_points[i].y+offSetY)*globalScale, (_points[i+1].x+offSetX)*globalScale, (_points[i+1].y+offSetY)*globalScale, _normalLinePaint);
			}
		}
	}
	
	public void CalcularConexiones(Componente father, Componente child){
		_numberOfPoints = 2;
		_points[0] = father.Anchor;
		_points[1] = child.Anchor;
	}
}
